package suse.hotel.admin.admin.Provider;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Random;

@Component
public class EmailProvide {
    @Autowired
    JavaMailSenderImpl javaMailSender;


    public void sendTo(String em,int orderId) {
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH：mm：ss：SSS");
        String str=sdf.format(System.currentTimeMillis());
        String mima = "您的订单"+orderId+"还没有付款请及时付款\n"+str;
        mailMessage.setSubject("催款");
        mailMessage.setText( mima);
        mailMessage.setTo(em);
        mailMessage.setFrom("1254852378@qq.com");
        javaMailSender.send(mailMessage);
    }
}

